angular.module('invoiceDetail', []).controller('invoiceDetailCtrl', [
    '$scope',
    'httpService',
    'alertmsg',
    '$stateParams',
    function($scope, httpService, alertmsg, $stateParams) {
        /* 根据ID查找发票的信息 start */
        var id = $stateParams.id;
        $scope.getInvoice = function() {
            httpService.query('web/users/' + id + '/fetch_invoiced_orders').then(function(res) {
                if (res.code == 200) {
                    console.log(res);
                    $scope.orders = res.orders;
                    $scope.invoice = res.invoice;
                } else {
                    alertmsg(res.msg);
                }
            });
        }
        $scope.getInvoice()
        /* 根据ID查找发票的信息 */

        /* 计算订单总价 start */
        $scope.orderTotal = function(total, measure_amount) {
            return parseFloat(total) + measure_amount;
        }
        /* 计算订单总价 end */
    }
]);
